﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Provider;

namespace AccessToDataLibrary
{
    public partial class AccessToDataLibrary
    {
        UniversityLibraryDataSet libraryDataSet;
        Provider.Provider provider = new Provider.Provider();

        public AccessToDataLibrary(SourceType dataType, string targetData)
        {
            this.libraryDataSet = this.provider.GetAllData(dataType, targetData);
        }

        private string MakeFilteredQuery(Dictionary<string, string> searchedTable)
        {
            string filter = string.Empty;
            if (searchedTable == null)
                return filter;
            foreach (KeyValuePair<string, string> kvp in searchedTable)
            {
                if (kvp.Value == null || kvp.Value == string.Empty)
                    continue;

                if (string.IsNullOrEmpty(filter))
                    filter += string.Format("[{0}] LIKE '%{1}%'", kvp.Key, kvp.Value);
                else
                    filter += string.Format(" AND [{0}] LIKE '%{1}%'", kvp.Key, kvp.Value);
            }
            return filter;
        }
    }
}
